package services

import (
	"context"
	"k8sdev/pkg/client"
	"log"

	v1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func GetNamespaces() (namespacesList *[]v1.Namespace, err error) {
	err = client.NewClient()
	if err != nil {
		log.Fatal(err.Error())
		return
	}
	client := client.GetClientSet()
	list, err := client.CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{})
	if err != nil {
		log.Fatal(err.Error())
	}
	namespacesList = &list.Items

	return
}
